package com.zhongkun.datahome.service.res.house;

import com.zhongkun.datahome.service.domain.CustomerHouse;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: lifengsheng
 * @Date: 2025/5/8 14:51
 * @Desc
 */
@Data
public class CustomerHouseSelectVo {
    @ApiModelProperty("楼栋号")
    private String buildingNum;

    @ApiModelProperty("房号列表")
    private List<HouseSelectVo> houseList;

    @Data
    public static class HouseSelectVo {
        @ApiModelProperty("房产id")
        private Long houseId;

        @ApiModelProperty("所属家庭id")
        private Long familyId;

        @ApiModelProperty("房号")
        private String roomNum;

        @ApiModelProperty("房产面积")
        private BigDecimal roomArea;

        @ApiModelProperty("户型名称")
        private String houseName;

        public static HouseSelectVo of(CustomerHouse customerHouse) {
            HouseSelectVo houseSelectVo = new HouseSelectVo();
            houseSelectVo.setHouseId(customerHouse.getId());
            houseSelectVo.setFamilyId(customerHouse.getFamilyId());
            houseSelectVo.setRoomNum(customerHouse.getRoomNum());
            houseSelectVo.setRoomArea(customerHouse.getRoomArea());
            houseSelectVo.setHouseName(customerHouse.getHouseName());
            return houseSelectVo;
        }
    }

    public static CustomerHouseSelectVo of(List<CustomerHouse> customerHouses, String buildingNum) {
        CustomerHouseSelectVo customerHouseSelectVo = new CustomerHouseSelectVo();
        customerHouseSelectVo.setBuildingNum(buildingNum);

        List<HouseSelectVo> houseList = customerHouses.stream().map(HouseSelectVo::of).collect(Collectors.toList());
        customerHouseSelectVo.setHouseList(houseList);
        return customerHouseSelectVo;
    }
}
